﻿
@{
    Layout = null;
}


<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="~/layui/css/layui.css" rel="stylesheet" />
    <link href="~/layuimini/css/public.css" rel="stylesheet" />
</head>
<body>
    <div class="layuimini-container">
        <div class="layuimini-main">


            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend>工序详情</legend>
            </fieldset>

            <form class="layui-form" action="" lay-filter="example">
                <input type="hidden" name="BillProcedureID" value="0" />
                <input type="hidden" name="ID" value="0" />
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">接收数</label>
                        <div class="layui-input-inline">
                            <input type="text" name="InQty" lay-verify="required|number" autocomplete="off" class="layui-input" id="InQty" >
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">返工数</label>
                        <div class="layui-input-inline">
                            <input type="text" name="FanQty" lay-verify="required|number" autocomplete="off" class="layui-input" id="FanQty">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">下传数</label>
                        <div class="layui-input-inline">
                            <input type="text" name="OutQty" lay-verify="required|number" autocomplete="off" class="layui-input" id="OutQty" >
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">废品数</label>
                        <div class="layui-input-inline">
                            <input type="text" name="FailQty" lay-verify="required|number" autocomplete="off" class="layui-input" id="FailQty">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">废品原因</label>
                        <div class="layui-input-inline">
                            <input type="text" name="FailRemark"  autocomplete="off" class="layui-input" id="FailRemark">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">操作员</label>
                        <div class="layui-input-inline">
                            <select name="OperatorUserID" lay-search id="OperatorUserID">
                                <option value="0">无</option>
                                @Html.Raw(ViewBag.Users)
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">开始日期</label>
                        <div class="layui-input-inline">
                            <input type="text" name="BeginDate" id="BeginDate" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" readonly="readonly">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">结束日期</label>
                        <div class="layui-input-inline">
                            <input type="text" name="EndDate" id="EndDate" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" readonly="readonly">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">工时(分钟)</label>
                        <div class="layui-input-inline">
                            <input type="text" name="TaskTime" lay-verify="number" autocomplete="off" class="layui-input" id="TaskTime" >
                        </div>
                    </div>
                    <div class="layui-inline" style="display:none;">
                        <label class="layui-form-label">操作日期</label>
                        <div class="layui-input-inline">
                            <input type="text" name="CreateDate" id="CreateDate" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" readonly="readonly">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">设备编号</label>
                        <div class="layui-input-inline">
                            <input type="text" name="SheBei" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                </div>
                @*<div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">测试者</label>
                        <div class="layui-input-inline">
                            <select name="CheckUserID" lay-search id="CheckUserID">
                                <option value="0">无</option>
                                @Html.Raw(ViewBag.Users)
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">测试日期</label>
                        <div class="layui-input-inline">
                            <input type="text" name="CheckDate" id="CheckDate" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" readonly="readonly">
                        </div>
                    </div>
                </div>*@

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">工艺条件</label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入内容" class="layui-textarea" name="GongYi"></textarea>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入内容" class="layui-textarea" name="Remark"></textarea>
                    </div>
                </div>



                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <script src="/layui/layui.js"></script>
    <script src="/scripts/jquery-1.4.4.min.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
    <script>
        layui.use(['form', 'layedit', 'laydate', 'jquery'], function () {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate
                , $ = layui.jquery
            //日期

            laydate.render({
                elem: '#CreateDate'
                , trigger: 'click'
            });
            laydate.render({
                elem: '#BeginDate'
                , trigger: 'click'
            });
            laydate.render({
                elem: '#EndDate'
                , trigger: 'click'
            });
            //监听提交
            form.on('submit(demo1)', function (data) {
                $.ajax({
                    url: '@Url.Action("BillDetailsEditAsync", "Bill6")',
                    type: 'post',
                    dataType: 'json',
                    data: data.field,
                    success: function (data) {
                        console.log(data);
                        //Info,Success,Warning,Error
                        var type = data.Type;
                        if (type == 1) {
                            layer.msg(data.Content, { icon: 6, time: 2000 },
                                function () {
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(index);
                                });

                        } else {
                            layer.alert(data.Content, { icon: 5 });
                        }
                    }
                });
                //layer.alert(JSON.stringify(data.field), {
                //    title: '最终的提交信息'
                //})
                return false;
            });

            //表单初始赋值
            form.val('example', {
                "ID": `@Html.Raw(ViewBag.Model.ID)`,
                "BillProcedureID": `@Html.Raw(ViewBag.Model.BillProcedureID)`,
                "InQty": `@Html.Raw(ViewBag.Model.InQty)`,
                "FanQty": `@Html.Raw(ViewBag.Model.FanQty)`,
                "OutQty": `@Html.Raw(ViewBag.Model.OutQty)`,
                "FailQty": `@Html.Raw(ViewBag.Model.FailQty)`,
                "FailRemark": `@Html.Raw(ViewBag.Model.FailRemark)`,
                "TaskTime": `@Html.Raw(ViewBag.Model.TaskTime)`,
                "CheckDate": `@Html.Raw(ViewBag.Model.CheckDate)`,
                "OperatorUserID": `@Html.Raw(ViewBag.Model.OperatorUserID)`,
                "CheckUserID": `@Html.Raw(ViewBag.Model.CheckUserID)`,
                "CreateDate": `@Html.Raw(ViewBag.Model.CreateDate)`,
                "GongYi": `@Html.Raw(ViewBag.Model.GongYi)`,
                "Remark": `@Html.Raw(ViewBag.Model.Remark)`,
                "BeginDate": `@Html.Raw(ViewBag.Model.BeginDate)`,
                "EndDate": `@Html.Raw(ViewBag.Model.EndDate)`,
                "SheBei": `@Html.Raw(ViewBag.Model.SheBei)`

            })
            $('#FailQty').change(function () {
                var inqty = $('#InQty').val();
                var failqty = $('#FailQty').val();
                var fanqty = $('#FanQty').val();
                var outqty = Number(inqty) + Number(fanqty) - Number(failqty);
                $('#OutQty').val(outqty);
            });
            $('#InQty').change(function () {
                var inqty = $('#InQty').val();
                var failqty = $('#FailQty').val();
                var fanqty = $('#FanQty').val();
                var outqty = Number(inqty) + Number(fanqty) - Number(failqty);
                $('#OutQty').val(outqty);
            });
            $('#FanQty').change(function () {
                var inqty = $('#InQty').val();
                var failqty = $('#FailQty').val();
                var fanqty = $('#FanQty').val();
                var outqty = Number(inqty) + Number(fanqty) - Number(failqty);
                $('#OutQty').val(outqty);
            });


        });

    </script>

</body>
</html>